﻿Public Class ServerForm

    Private Sub CustomersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomersBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.CustomersBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.CRMDataSet)

    End Sub

    Private Sub ServerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'CRMDataSet.Customers' table. You can move, or remove it, as needed.
        Me.CustomersTableAdapter.Fill(Me.CRMDataSet.Customers)

    End Sub

    Private Sub CustomersBindingSource_CurrentChanged _
                     (ByVal sender As System.Object, ByVal e As System.EventArgs) _
                                      Handles CustomersBindingSource.CurrentChanged
        Dim c As CRMDataSet.CustomersRow = _
                       CType(CType(Me.CustomersBindingSource.CurrencyManager.Current,  _
                                    DataRowView).Row,  _
                             CRMDataSet.CustomersRow)
        If c.RowState = DataRowState.Detached Then
            c.CustomerId = Guid.NewGuid
        End If
    End Sub

End Class